home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: new-news.sprintlink.net!news1!ind-004-236-171
- From: dlmiller@iquest.net (Doug Miller)
- Subject: Re: String Upper/Lower--void main an error?
- X-Nntp-Posting-Host: ind-004-236-171.iquest.net
- Message-ID: <DooA9I.HI4@iquest.net>
- Sender: news@iquest.net (News Admin)
- Organization: IQuest Network Services
- X-Newsreader: News Xpress Version 1.0 Beta #2.1
- References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net> <4ini70$8j@vodka.intele.net>
- Date: Fri, 22 Mar 1996 14:17:28 GMT
-
- cjmorgan@intele.net (Jason V. Morgan) wrote:
- +Xref: news1 comp.lang.c:71136
- +Path: news1!news.sprintlink.net!new-news.sprintlink.net!news.sprintlink.net!psgrain!news.uoregon.edu!xmission!inteleNET!usenet
- +From: cjmorgan@intele.net (Jason V. Morgan)
- +Newsgroups: comp.lang.c
- +Subject: Re: String Upper/Lower--void main an error?
- +Date: 20 Mar 1996 00:06:56 GMT
- +Organization: inteleNET Internet Services
- +Lines: 37
- +Message-ID: <4ini70$8j@vodka.intele.net>
- +References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net>
- +NNTP-Posting-Host: 206.29.210.151
- +Mime-Version: 1.0
- +Content-Type: Text/Plain; charset=US-ASCII
- +X-Newsreader: WinVN 0.99.7
- +
- +>>void main (void) {
- +>
- +>Oh, please! Read the FAQ to avoid posting crap like this.
- +>
- +>>char test[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ";
- +>>char *p;
- +>>
- +>>printf ("%s\n", &test);
- +>
- +>&test ??? How about just test?
- +>
- +>>for (p = test; *p; *p++)
- +>
- +>And what do you think you are accomplishing with *p++ that p++ or ++p
- +>wouldn't do???
- +>
- +>> if (isalpha(*p)) *p ^= 0x20; /* for ascii machines e.g. PC; use 0x40 for
- +ebcdic machines e.g. IBM mainframe */
- +>
- +>isalpha() has not been declared. It takes an int and *p may be a signed
- +>char, how about *(unsigned char *)p. Also, your code is toggling between
- +>upper and lower case.
-
- OF COURSE the code toggles between upper and lower case -- that's what he asked for.
-
- +
- +>>printf ("%s\n", &test);
- +>
- +>There you go again with this &test thingy. Finally, you'll want a
- +>"return 0;" after you've fixed the "void main" error.
- +
- +I don't thing that void main is really considered to be an error. Return
- +values are only really necessary if they're going to mean anything. It is
- +compilable (maybe I'm wrong and it's not portable). At least it was declared
- +void so it didn't default to an int. You might as well say that it's an error
- +because argc, argv, and env weren't passed (to be honest, I'm not sure if env
- +is actually standard, I got it from the programmer's reference, not the
- +standard).
- + --Jason V. Morgan
- +
-
-